# -*- coding: utf-8 -*-
from django.db import models
from django.contrib import admin

import sys
reload(sys)
sys.setdefaultencoding('utf8')

# Create your models here.
class Course(models.Model):
	CourseID = models.IntegerField(primary_key = True,verbose_name = u'课程ID')
	CourseName = models.CharField(max_length = 30,verbose_name = u'课程名称')

	def __unicode__(self):
		return self.CourseID + '_' + self.CourseName

class Student(models.Model):
	StudentID = models.IntegerField(primary_key = True,verbose_name = u'学生ID')
	StudentName = models.CharField(max_length = 20,verbose_name = u'学生姓名')
	GENDER_CHOICES = ((True,'男性'),(False,'女性'))
	StudentGender = models.NullBooleanField(choices = GENDER_CHOICES,verbose_name = u'性别')
	StudentAge = models.IntegerField (verbose_name = u'年龄')
	StudentPassword = models.CharField(max_length = 30,verbose_name = u'密码')
	StudentEmail = models.EmailField(verbose_name = u'Email')

	def __unicode__(self):
		return self.StudentID + '_' + self.StudentName

class Teacher(models.Model):
	TeacherID = models.IntegerField(primary_key = True,verbose_name = u'教师ID')
	TeacherName = models.CharField(max_length = 20,verbose_name = u'教师姓名')
	GENDER_CHOICES = ((True,'男性'),(False,'女性'))
	TeacherGender = models.NullBooleanField(choices = GENDER_CHOICES,verbose_name = u'性别')
	TeacherAge = models.IntegerField(verbose_name = u'年龄')
	TeacherPassword = models.CharField(max_length = 30,verbose_name = u'密码')
	TeacherEmail = models.EmailField(verbose_name = u'Email')

	def __unicode__(self):
		return self.TeacherID + '_' + self.TeacherName

class JudgeProblem(models.Model):
	JudgePeoblemID = models.IntegerField(primary_key = True,verbose_name = u'判断题ID')
	CourseID = models.IntegerField(verbose_name = u'科目ID')
	ExamID = models.IntegerField(verbose_name = u'试卷ID')
	JudgeTitle = models.CharField(max_length = 2000,verbose_name = u'题目')
	OptionA = models.CharField(max_length = 50,default = '正确',verbose_name = u'正确')
	OptionB = models.CharField(max_length = 50,default = '错误',verbose_name = u'错误')
	JudgeAnswer = models.CharField(max_length = 10,verbose_name = u'答案')

	def __unicode__(self):
		return '判断题' + self.JudgeProblemID

class SingleProblem(models.Model):
	SingleProblemID = models.IntegerField(primary_key = True,verbose_name = u'单选题ID')
	CourseID = models.CharField(max_length = 20,verbose_name = u'科目名称')
	ExamID = models.CharField(max_length = 40,verbose_name = u'试卷名称')
	SingleTitle = models.CharField(max_length = 2000,verbose_name = u'题目')
	OptionA = models.CharField(max_length = 500,verbose_name = u'选项A')
	OptionB = models.CharField(max_length = 500,verbose_name = u'选项B')
	OptionC = models.CharField(max_length = 500,verbose_name = u'选项C')
	OptionD = models.CharField(max_length = 500,verbose_name = u'选项D')
	SingleAnswer = models.CharField(max_length = 20,verbose_name = u'答案')

	def __unicode__(self):
		return  '单选题' + '_' + str(self.SingleProblemID)

class MultiProblem(models.Model):
	MultiProblemID = models.IntegerField(primary_key = True,verbose_name = u'多选题ID')
	CourseID = models.IntegerField(verbose_name = u'课程ID')
	ExamID = models.IntegerField(verbose_name = u'试卷ID')
	MultiTitle = models.CharField(max_length = 2000,verbose_name = u'题目')
	OptionA = models.CharField(max_length = 500,verbose_name = u'选项A')
	OptionB = models.CharField(max_length = 500,verbose_name = u'选项B')
	OptionC = models.CharField(max_length = 500,verbose_name = u'选项C')
	OptionD = models.CharField(max_length = 500,verbose_name = u'选项D')
	MultiAnswer = models.CharField(max_length = 20,verbose_name = u'答案')

	def __unicode__(self):
		return '多选题' + self.MultiProblemID

class ShortProblem(models.Model):
	ShortProblemID = models.IntegerField(primary_key = True,verbose_name = u'简答题ID')
	CourseID = models.IntegerField(verbose_name = u'课程ID')
	ExamID = models.IntegerField(verbose_name = u'试卷ID')
	ShortTitle = models.CharField(max_length = 2000,verbose_name = u'题目')
	ShortAnswer = models.CharField(max_length = 3000,verbose_name = u'答案')

	def __unicode__(self):
		return '简答题' + self.ShortProblemID

class ExamPaperInfo(models.Model):
	CourseID = models.CharField(max_length = 20,verbose_name = u'科目名称')
	ExamID = models.CharField(primary_key = True,max_length = 40,verbose_name = u'试卷名称')
	ExamTime = models.IntegerField(verbose_name = u'考试时长')
	TotalScore = models.IntegerField(verbose_name = u'总分')
	TeacherID = models.IntegerField(verbose_name = u'教师ID')
	#ExamState = models.IntegerField(verbose_name = u'试卷状态')
	#ExamType = models.IntegerField(verbose_name = u'试卷类型')

	def __unicode__(self):
		return self.ExamID

class ExamPaperDetailOfQuestion(models.Model):
	ExamID = models.IntegerField(verbose_name = u'试卷ID')
	QustionID = models.IntegerField(verbose_name = u'题目ID')
	QustionType = models.CharField(max_length = 10,verbose_name = u'题目类型')
	QustionOrder = models.IntegerField(verbose_name = '序号')
	QustionScore = models.IntegerField(verbose_name = '分数')

	def __unicode__(self):
		return '题目' + self.QuestionID

class ExamPaperTypeOfQuestion(models.Model):
	ExamID = models.IntegerField(verbose_name = u'试卷ID')
	TypeOrder = models.IntegerField(verbose_name = u'题目顺序')
	QustionType = models.CharField(max_length = 10,verbose_name = u'题目类型')
	TypeNum = models.IntegerField(verbose_name = u'此题型数量')
	TypeScore = models.IntegerField(verbose_name = u'此题型总分')

	def __unicode__(self):
		return '试卷问题类型' + id

class ExamPaperDetailOfAnswered(models.Model):
	AnsweredID = models.IntegerField(verbose_name = '作答ID')
	QuestionID = models.IntegerField(verbose_name = '题目ID')
	QustionType = models.CharField(max_length = 10,verbose_name = u'题目类型')
	StuAnswer = models.CharField(max_length = 10,verbose_name = u'学生答案')
	StandardAnswer = models.CharField(max_length = 10,verbose_name = u'标准答案')
	QuestionScore = models.IntegerField(verbose_name = '此题分数')
	StuScore = models.IntegerField(verbose_name = '此题得分')

	def __unicode__(self):
		return '作答详情' + id

class ExamPaperAnsweredInfo(models.Model):
	AnsweredID = models.IntegerField(primary_key = True,verbose_name = '作答ID')
	ExamID = models.IntegerField(verbose_name = '试卷ID')
	StudentID = models.IntegerField(verbose_name = '学生ID')
	ExamState = models.IntegerField(verbose_name = u'试卷状态')
	TotalMark = models.IntegerField(verbose_name = '作答总分')

	def __unicode__(self):
		return '作答' + self.AnsweredID




